
package gblend.formatcovert;

/**
 *
 * @author cjjin
 */
/*
* Copyright 2010, Center for Advanced Information Systems, Nanyang Technological University
*
* File name: QuickSIQuery.java
*
* Abstract: Convert the query format to QuickSI
*
* Current Version:      0.1
* Auther:               Jin Changjiu
* Modified Date:        June.3,2009
*
*/
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Vector;


public class QuickSIQuery {

    private static Vector<String> graphlist = new Vector<String>();
    private static String filename  = null;

    public static void main (String[] args) throws FileNotFoundException
    {
         formatDotFile(args[0]);
    }


    public static void formatDotFile(String filename)
    {
	String output1=filename+".n";
        String strLine = null;
	FileOutputStream outStream1;
	PrintStream p;
        PrintStream q;
	FileInputStream inStream;
	DataInputStream in;
	BufferedReader br;

	File fin=new File(filename);
	File fout1=new File(output1);
        if(fin.exists())
	{
            try {

        	outStream1=new FileOutputStream(fout1,false);
                inStream=new FileInputStream(fin);
		// Connect print stream to the output stream
                p = new PrintStream( outStream1 );
               // Get the object of DataInputStream
                in = new DataInputStream(inStream);
                br = new BufferedReader(new InputStreamReader(in));
		//Read file line by line
    		try {
                     
                      while ((strLine = br.readLine()) != null)
                      {
                        graphlist.addElement(strLine);
                      }

                      for(int i = 0;i<1000;i++)
                      {
                         for(int j = 0;j<graphlist.size();j++)
                         {
                            p.println(graphlist.elementAt(j));
                         }

                      }

                    //Close the input stream
                    in.close();
                    p.close();

		}
		catch (IOException e)
		{
		// TODO Auto-generated catch block
                    e.printStackTrace();
		}
                } catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
                    e.printStackTrace();
		}
            }

	}


}
